package org.hagopa.games.moneypool.game;


import org.hagopa.games.moneypool.dblayer.PlayerDataAdopt;
import org.hagopa.games.moneypool.network.IClientHandler;

public class PlayerHolder {
	private int gId = 0;
	private IClientHandler clientHandler= null;
        private String PlayerName="";
	private long cid = 0;
	private int cash = 0;
	private boolean netClient = true;
	private int type = 1;   // 0 - view, 1 - play - temporary default 1
	private int currPosition = 1;
	private int turnStatus = -1; // turn status 0 - READY 1- before throw dies, 2 after
	private PlayerDataAdopt pda;
        private int playerType = 0;

	public int getTurnStatus() {
		return turnStatus;
	}

	public void setTurnStatus(int turnStatus) {
		this.turnStatus = turnStatus;
	}
        public int getPlayerType()
        {
            return this.playerType;
        }

        public void setViewer()
        {
            this.playerType = 0;
        }
        public void setActive()
        {
            this.playerType = 1;
        }
	public int getCurrPosition() {
		return currPosition;
	}

	public void setCurrPosition(int currPosition, int offset)
        {
		if(offset == 0)
		{
			this.currPosition += currPosition;
		}
		else
		{
			this.currPosition = currPosition;
		}
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public PlayerHolder(long cid)
	{
            this.cid = cid;
            this.pda = new PlayerDataAdopt(this.cid);
            this.pda.requestDB();
            this.PlayerName = this.pda.getUsername();
            System.out.println("(PlayerHolder) - Starting Player Holder: "+ this.PlayerName);
                
	}
	public String getName()
	{
		return this.PlayerName;
	}
	public int getCash() {
		return cash;
	}
	public void setCash(int cash) {
		this.cash = cash;
		
	}
	public int getGId() {
		return gId;
	}
	public void setGId(int id) {
		gId = id;
	}
	public IClientHandler getClientHandler() {
		return clientHandler;
	}
	public void setClientHandler(IClientHandler clientHandler, boolean ifNet) {
		this.clientHandler = clientHandler;
		this.netClient = ifNet;
	}

	public boolean isNetClient() {
		return netClient;
	}

	public void setNetClient(boolean netClient) {
		this.netClient = netClient;
	}

	public void printStatus()
        {
            System.out.println("(PlayerHolder) - print Status of Player: [id=" + this.cid + ", name=" + this.PlayerName + " ]" );
            System.out.println("------------------------------------------------------------------------");
            System.out.println("Game Id:" + this.gId);
            System.out.println("Cash :" + this.cash);
            System.out.println("Current Position on Board:" + this.currPosition);
            System.out.println("------------------------------------------------------------------------");

        }
	
}
